package com.jackiechan.hello.day03;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 使用Date输出当前系统时间，以及3天后这一刻的时间
 * @author Xiloer
 *
 */
public class Test01 {
    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat();
        sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        System.out.println("现在时间：" + sdf.format(date));

        Calendar now  = Calendar.getInstance();
        now.setTime(date);
        now.set(Calendar.DATE, now.get(Calendar.DATE)+3 );

//        System.out.println("3天后：" +sdf.format(now.getTime()));


        Calendar birthday = Calendar.getInstance();
        birthday.set(2021, 3, 17);
        System.out.println("生日时间："+sdf.format(birthday.getTime()));

        int year = birthday.get(Calendar.YEAR) - now.get(Calendar.YEAR);
        int month = birthday.get(Calendar.MONTH) - now.get(Calendar.MONTH);
        int day = birthday.get(Calendar.DATE) - now.get(Calendar.DATE);
        System.out.println("距离生日还有："+ month +" 月 "+day+" 天");

        System.out.println(birthday.getLeastMaximum(Calendar.YEAR));
        System.out.println(birthday.getLeastMaximum(Calendar.MONTH));
        System.out.println(birthday.getLeastMaximum(Calendar.DATE));
    }

}
